package com.woniu.microworkorderserver.businessmag.service.impl;

import com.woniu.microcommonsserver.entity.InspectPointInfoEntity;
import com.woniu.microcommonsserver.entity.PollingTemplateInfoEntity;
import com.woniu.microworkorderserver.businessmag.mapper.InspectPointMapper;
import com.woniu.microworkorderserver.businessmag.mapper.InspectTemplateMapper;
import com.woniu.microworkorderserver.businessmag.service.InspectPointService;
import com.woniu.microworkorderserver.param.InspectPointMap;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class InspectPointServiceImpl implements InspectPointService {

    @Resource
    private InspectPointMapper inspectPointMapper;
    @Resource
    private InspectTemplateMapper inspectTemplateMapper;

    @Override
    public long save(InspectPointInfoEntity entity) {
        return 0;
    }

    @Override
    public InspectPointMap findByPlanId(long inspectPlanId) {
        List<InspectPointInfoEntity> list = inspectPointMapper.findByPlanId(inspectPlanId);
        InspectPointMap map = new InspectPointMap();
        if(list.size() > 0){
            InspectPointInfoEntity entity = list.get(0);
            map.setFkInspectTemName(inspectTemplateMapper.findById(entity.getFkInspectTemId()).getTemplateName());
            map.setId(entity.getId());
            map.setLocation(entity.getLocation());
            map.setType(entity.getType());
            map.setInspectPoint(entity.getInspectPoint());
        }

        return map;
    }
}
